//UIText跟随物体显示标题
using UnityEngine;

public class UIFollowObject : MonoBehaviour
{
    public Transform target;
    public float yOffset = 0;
    
    void Update ()
    {
        Vector3 namePos = Camera.main.WorldToScreenPoint(this.transform.position);
        namePos.z = 0;
        namePos.y += yOffset;
        target.position = namePos;
    }
}
